#include "serialportthread.h"
#include <iostream>
#include <QMutexLocker>

// 线程
SerialportThread::SerialportThread(QObject *parent) :
    QThread(parent)
{
    m_stop = false;
//    connect(this,&SerialportThread::finished,this,[=](){
//       this->deleteLater();
//    });
}

SerialportThread::~SerialportThread()
{
    requestInterruption();
    wait();
}


// 线程运行
void SerialportThread::run()
{
    QByteArray tempVar;
    while(!m_stop)
    {
        while(!g_rcvDataQueue.isEmpty())
        {
            tempVar = g_rcvDataQueue.dequeue();
            emit newDataRcved(tempVar);
        }
    }
}


